/**
 * Copyright (c) 2014-2015, Suredy technology Co., Ltd. All rights reserved.
 * @author ZhangMaoren 
 * @since 2015年4月14日
 * @version 0.1
 */
package com.suredy.config.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

import com.suredy.config.model.FileTypeConfig;
import com.suredy.core.service.BaseSrvWithEntity;


/**
 * @author ZhangMaoren
 *
 */
@Service
public class FileTypeConfigSrv extends BaseSrvWithEntity<FileTypeConfig>{
	public List<FileTypeConfig> getAll() {
		return this.readByEntity(null);
	}
	
	public FileTypeConfig get(String id) {
		return super.get(id);
	}
	
	public FileTypeConfig getFileTypeByCode(String fileTypeCode) {
		FileTypeConfig ret = null;
		DetachedCriteria dc = DetachedCriteria.forClass(FileTypeConfig.class);
		dc.add(Restrictions.eq("flowUN",fileTypeCode));
		ret = (FileTypeConfig) super.readSingleByCriteria(dc);
		
		return ret;
	}
	
	
	public List<FileTypeConfig> getFileTypeByAppId(String appId) {
		DetachedCriteria dc = DetachedCriteria.forClass(FileTypeConfig.class);
		dc.add(Restrictions.eq("appId",appId));
		@SuppressWarnings("unchecked")
		List<FileTypeConfig> ret = (List<FileTypeConfig>) super.readByCriteria(dc); 
		return ret; 
	}

	public void add(FileTypeConfig config) {
		this.saveOrUpdate(config);
	}
	
	public void update(FileTypeConfig config) {
		this.update(config);
	}
	
	public void remove(FileTypeConfig config) {
		this.delete(config);
	}
}
